home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume11 / id / part01 next >
Encoding:
Internet Message Format  |  1987-09-25  |  37.4 KB

  1. Subject:  v11i078:  C cross-reference database system, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: sun!suneast!kumquat!gmcgary (Greg Mcgary - Sun ECD Software)
  7. Posting-number: Volume 11, Issue 78
  8. Archive-name: id/Part01
  9.  
  10. This is a program identifier database package.  These tools provide a
  11. logical extension to ctags. (which is limited in that it only stores the
  12. location of function and type *definitions*).  The ID facility stores the
  13. locations for all uses of identifiers, pre-processor names, and numbers
  14. (in decimal, octal or hex).  The id-database is most useful for
  15. maintaining large programs that consist of many source files.  The
  16. database is simply a two dimensional boolean array indexed by
  17. identifier-name and source-file-name.  For a given identifier and
  18. source-file, if the identifier occurs in the file, the boolean value is
  19. TRUE.  The database may be queried either by identifier-name or
  20. file-name.
  21.  
  22.  
  23. #! /bin/sh
  24. # This is a shell archive, meaning:
  25. # 1. Remove everything above the #! /bin/sh line.
  26. # 2. Save the resulting text in a file.
  27. # 3. Execute the file with /bin/sh (not csh) to create the files:
  28. #    TUTORIAL
  29. #    TODO
  30. #    makefile
  31. #    bitops.h
  32. #    bool.h
  33. #    extern.h
  34. #    id.h
  35. #    patchlevel.h
  36. #    radix.h
  37. #    string.h
  38. #    lid.1
  39. #    mkid.1
  40. export PATH; PATH=/bin:$PATH
  41. echo shar: extracting "'TUTORIAL'" '(16037 characters)'
  42. sed 's/^X//' << \SHAR_EOF > 'TUTORIAL'
  43. X
  44. XThis is a program identifier database package.  These tools provide a
  45. Xlogical extension to ctags. (which is limited in that it only stores the
  46. Xlocation of function and type *definitions*a)  The ID facility
  47. Xstores the locations for all uses of identifiers, pre-processor
  48. Xnames, and numbers. (in decimal, octal or hex)
  49. X
  50. XWhen fixing or enhancing a large program (particularly one that is
  51. Xunfamiliar) it is often necessary to audit the use of global
  52. Xdata-structures in order to verify that the proposed modification will
  53. Xnot trigger any hidden `gotchas'.  Often this entails grepping through
  54. Xmany thousands of lines of source code spread over dozens and sometimes
  55. Xhundreds of source files in multiple sub-directories.  This process
  56. Xplaces a significant load on computing resources, and takes a long
  57. Xtime.  There is even the danger that a programmer will avoid doing a
  58. Xcomplete audit due to the perceived cost--he or she will rely on memory
  59. Xand hope that there are no booby traps.
  60. X
  61. XThe id-database is most useful for maintaining large programs that
  62. Xconsist of many source files.  The database is simply a two dimensional
  63. Xboolean array indexed by identifier-name and source-file-name.  For a
  64. Xgiven identifier and source-file, if the identifier occurs in the file,
  65. Xthe boolean value is TRUE.  The database may be queried either by
  66. Xidentifier-name or file-name.
  67. X
  68. XThe following types of queries supported:
  69. X
  70. X* name lookup
  71. X    list all the files where an identifier occurs.  The name
  72. X    may be a regular expression.
  73. X
  74. X* name apropos
  75. X    list all the files for all identifiers that have the sub-string
  76. X    name in them.  Matches are done in a case-insensitive mammer.
  77. X
  78. X* name `grep'
  79. X    search for an identifier in all the files where it occurs.
  80. X    This is an optimized `grep' over all the sources--we only
  81. X    search on files that contain the identifier.
  82. X
  83. X* name edit
  84. X    invoke an editor on the files where an identifier occurs,
  85. X    and use the identifier as an initial search string.
  86. X
  87. X* file lookup
  88. X    list all identifiers that occur in a file, or list
  89. X    the identifiers that are common between two files.
  90. X
  91. X* non-unique names
  92. X    list the names of all indentifiers whose names are non-unique
  93. X    within some number of characters.  This is useful when porting
  94. X    a program from a `flexnames' system to one more limited names.
  95. X
  96. X* solo
  97. X    list all identifiers that occur exactly once in a software
  98. X    system.  This may be useful for locating identifiers that are
  99. X    declared but never used, or library functions that are used
  100. X    but never declared.
  101. X    
  102. X
  103. XThe first four queries are handled by one program.  The type of query
  104. Xis determined by the name the program was invoked with.  The four links
  105. Xare lid(1) for `lookup id', aid(1) for `apropos id', gid(1) for `grep
  106. Xid' and eid(1) for `edit id'.  One or more identifiers may be passed on
  107. Xthe command line.  The identifiers may be literal strings or regular
  108. Xexpressions.  Here are some examples:
  109. X
  110. X$ lid FILE
  111. XFILE           extern.h {fid,gets0,getsFF,idx,init,lid,mkid,opensrc,scan-asm,scan-c}.c
  112. X
  113. X$ lid FILE$
  114. XAF_FILE        mkid.c
  115. XAF_IDFILE      mkid.c
  116. XFILE           extern.h {fid,gets0,getsFF,idx,init,lid,mkid,opensrc,scan-asm,scan-c}.c
  117. XIDFILE         id.h {fid,lid,mkid}.c
  118. XIdFILE         {fid,lid}.c
  119. XargFILE        mkid.c
  120. XgidFILE        lid.c
  121. XidFILE         {init,mkid}.c
  122. XinFILE         {gets0,getsFF,scan-asm,scan-c}.c
  123. XopenSrcFILE    extern.h {idx,mkid,opensrc}.c
  124. XsrcFILE        {idx,mkid,opensrc}.c
  125. X
  126. X$ lid ^get
  127. Xget            opensrc.c
  128. XgetAdaId       getscan.c
  129. XgetAsmId       extern.h {getscan,scan-asm}.c
  130. XgetCId         extern.h {getscan,scan-c}.c
  131. XgetDirToName   extern.h {fid,lid,paths}.c
  132. XgetId          {idx,mkid}.c
  133. XgetLanguage    extern.h {getscan,idx,mkid}.c
  134. XgetLispId      getscan.c
  135. XgetPascalId    getscan.c
  136. XgetRoffId      getscan.c
  137. XgetSCCS        extern.h opensrc.c
  138. XgetScanner     extern.h {getscan,idx,mkid}.c
  139. XgetTeXId       getscan.c
  140. XgetTextId      getscan.c
  141. Xgetc           {gets0,getsFF,lid,scan-asm,scan-c}.c
  142. Xgetchar        lid.c
  143. Xgetenv         extern.h lid.c
  144. Xgets           lid.c
  145. XgetsFF         extern.h {bitsvec,fid,getsFF,lid,mkid}.c
  146. X
  147. XAs you can see, when a regular expression is used, it is possible to
  148. Xget more than one line of output.  If you wish multiple lines to be
  149. Xmerged into one, supply the `-m' option:
  150. X
  151. X$ lid -m ^get
  152. X^get           extern.h {bitsvec,fid,gets0,getsFF,getscan,idx,lid,mkid,opensrc,paths,scan-asm,scan-c}.c
  153. X
  154. XThe query program searches for numbers numerically rather than
  155. Xtextually.  Therefore you may search for multiple representations of a
  156. Xnumber.  It is best to illustrate this with examples:
  157. X
  158. X$ lid -a 0x10
  159. X020            numtst.c
  160. X0x00010        numtst.c
  161. X0x0010         scan-c.c
  162. X0x10           {id,radix}.h {scan-asm,stoi}.c
  163. X16             numtst.c
  164. X
  165. XThe `-a' argument tells lid(1) to look for 0x10 in all radixes.  (For
  166. Xnumbers 0 through 7, lid(1) looks for all radixes by default.  For numbers
  167. Xgreater than 7, lid(1) only looks for the radix that the argument is
  168. Xsupplied in.) It is also possible to restrict the search to selected
  169. Xradixes by supplying an argument consisting of one or more of the
  170. Xkey-letters `o', `d', and `x' for octal decimal and hexadecimal
  171. Xrespectively:
  172. X
  173. X$ lid -o 0x10
  174. X020            numtst.c
  175. X
  176. X$ lid -x 16
  177. X0x00010        numtst.c
  178. X0x0010         scan-c.c
  179. X0x10           {id,radix}.h  {scan-asm,stoi}.c
  180. X
  181. X$ lid -d 020
  182. X16             numtst.c
  183. X
  184. X
  185. XThe grep interface behaves somewhat like the following command:
  186. X
  187. X$ grep -w -n `lid TRUE`
  188. X
  189. XHeres some sample output for the equivalent gid command:
  190. X
  191. X$ gid TRUE
  192. Xbool.h:5: #define    TRUE    (0==0)
  193. Xlid.c:102:         case 'm': forceMerge = TRUE; break;
  194. Xlid.c:170:             Merging = TRUE;
  195. Xlid.c:204:             crunching = TRUE;
  196. Xlid.c:553:             hitDigits = TRUE;
  197. Xlid.c:787:             return TRUE;
  198. Xmkid.c:117:             Verbose = TRUE;
  199. Xmkid.c:191:                     keepLang = TRUE;
  200. Xscan-asm.c:79: static bool eatUnder = TRUE;
  201. Xscan-asm.c:80: static bool preProcess = TRUE;
  202. Xscan-asm.c:96:     static bool    newLine = TRUE;
  203. Xscan-asm.c:130:         newLine = TRUE;
  204. Xscan-asm.c:141:         newLine = TRUE;
  205. Xscan-asm.c:145:         newLine = TRUE;
  206. Xscan-asm.c:150:         newLine = TRUE;
  207. Xscan-asm.c:165:                 newLine = TRUE;
  208. Xscan-c.c:88: static bool eatUnder = TRUE;
  209. Xscan-c.c:101:     static bool    newLine = TRUE;
  210. Xscan-c.c:138:         newLine = TRUE;
  211. Xscan-c.c:199:                 newLine = TRUE;
  212. Xscan-c.c:205:         newLine = TRUE;
  213. Xscan-c.c:210:             newLine = TRUE;
  214. Xwmatch.c:37:             return TRUE;
  215. X
  216. XNotice that each line is reported in the same format as a
  217. XC-preprocessor error message.  This feature allows gid(1) lines to be
  218. Xdigested by any program that parses error messages, such as error(1)
  219. Xand gnu-emacs.
  220. X
  221. XIf you want to edit all files that have an identifier, you may
  222. Xconveniently do so with eid(1):
  223. X
  224. X$ eid TRUE
  225. XTRUE           bool.h {lid,mkid,scan-asm,scan-c,wmatch}.c
  226. XEdit? [y1-9^S/nq] 
  227. X
  228. XBefore the editor is invoked, you are given the lid(1) output to review
  229. Xand comfirm.  If you want to edit all files listed, respond with a
  230. Xnewline or with `y'.  If you want to skip some number of files into the
  231. Xargument list, respond with a single digit `1' through `9' to skip that
  232. Xmany files, or do a string-search to the first file you want with
  233. X`^S<string>' or `/<string>'.  If you don't want to edit anything, type
  234. X`n' to go on to the next argument you gave to eid(1) or type `q' to
  235. Xquit altogether.
  236. X
  237. XThe behavior of the editing interface is controlled by three
  238. Xenvironment variables called EIDARG, EIDLDEL, and EIDRDEL.  The best
  239. Xway to illustrate their use by an example.  Here is how to define them
  240. Xfor vi(1) (using /bin/sh syntax)
  241. X
  242. XEIDARG='+/%s/'    # printf(3) string for initial search-string argument
  243. XEIDLDEL='\<'    # left word-delimiter
  244. XEIDRDEL='\>'    # right word-delimiter
  245. X
  246. X`EID[LR]DEL' are positioned around the identifier as left and right
  247. Xword-delimiters if your editor supports that notion.  Then the whole
  248. Xname-string is sprintf(3)'ed into `EIDARG' to construct the initial
  249. Xsearch-string argument to the editor.  If your editor can't digest such
  250. Xan argument, simply leave these variables undefined in the
  251. Xenvironment.
  252. X
  253. XSome emacs users are appalled at the notion of starting up a fresh editor
  254. Xsimply to follow an identifier.  For those who are fortunate enough to have
  255. Xa programmable emacs such as gnu-emacs, it is fairly simple to devise
  256. Xa command that invokes gid(1) and digests its output as though it were
  257. X/lib/cpp error strings to be examined.  (Sorry, no such code is provided
  258. Xat this posting...)
  259. X
  260. XAnother type of query is to find all identifiers that are non-unique
  261. Xwithin some number of characters.  This is useful for finding potential
  262. Xportability problems when moving to a system whose compiler or linker
  263. Xlimits the number of significant characters in a name.  The `-u<n>'
  264. Xargument does the trick.  Here's a list of identifiers that may yield
  265. Xmultiply-defined errors in a symbol table that only knows about the
  266. Xfirst 7 characters:
  267. X
  268. X$ lid -u7
  269. XSCAN_TEX       getscan.c
  270. XSCAN_TEXT      getscan.c
  271. Xidh_argc       id.h {init,mkid}.c
  272. Xidh_argo       id.h {init,mkid}.c
  273. Xidh_namc       id.h {fid,mkid}.c
  274. Xidh_namo       id.h {fid,init,lid,mkid}.c
  275. XoldHashSize    mkid.c
  276. XoldHashTable   mkid.c
  277. X
  278. XBetter yet, if you want to edit these, try
  279. X
  280. X$ eid -u7
  281. X^SCAN_TE       getscan.c
  282. XEdit? [y1-9^S/nq] n
  283. X^idh_arg       getscan.c id.h {init,mkid}.c
  284. XEdit? [y1-9^S/nq] n
  285. X^idh_nam       {fid,getscan}.c id.h {init,lid,mkid}.c
  286. XEdit? [y1-9^S/nq] n
  287. X^oldHash       {fid,getscan}.c id.h {init,lid,mkid}.c
  288. XEdit? [y1-9^S/nq] n
  289. X
  290. X
  291. XAn additional feature of lid(1) is that pathnames are automatically
  292. Xadjusted for the current working directory.  Large programs such as the
  293. XUNIX kernel are often partitioned into subsystems whose sources live in
  294. Xdifferent directories.  What follows are several examples of the same
  295. Xsearch conducted from different points in the UNIX kernel source
  296. Xhierarchy:
  297. X
  298. X$ cd /src/uts/m68k
  299. X$ lid bdevsw
  300. Xbdevsw         sys/conf.h  cf/conf.c  io/bio.c  os/{fio,main,prf,sys3}.c
  301. X
  302. X$ cd io
  303. X$ lid bdevsw
  304. Xbdevsw         ../sys/conf.h  ../cf/conf.c  bio.c  ../os/{fio,main,prf,sys3}.c
  305. X
  306. X$ cd ../os
  307. Xbdevsw         ../sys/conf.h  ../cf/conf.c  ../io/bio.c  {fio,main,prf,sys3}.c
  308. X
  309. XThe database is built with mkid(1).  The user supplies pathnames
  310. Xeither on the command line or on stdin.  Here's the output of the
  311. X`verbose' option to mkid(1):
  312. X
  313. X$ mkid -v *.h *.c
  314. Xc: bitops.h
  315. Xc: bool.h
  316. Xc: extern.h
  317. Xc: id.h
  318. Xc: patchlevel.h
  319. Xc: radix.h
  320. Xc: string.h
  321. Xc: basename.c
  322. Xc: bitcount.c
  323. Xc: bitops.c
  324. Xc: bitsvec.c
  325. Xc: bsearch.c
  326. Xc: bzero.c
  327. Xc: document.c
  328. Xc: fid.c
  329. Xc: gets0.c
  330. Xc: getsFF.c
  331. Xc: getscan.c
  332. Xc: hash.c
  333. Xc: idx.c
  334. Xc: init.c
  335. Xc: lid.c
  336. Xc: mkid.c
  337. Xc: numtst.c
  338. Xc: opensrc.c
  339. Xc: paths.c
  340. Xc: scan-asm.c
  341. Xc: scan-c.c
  342. Xc: stoi.c
  343. Xc: tty.c
  344. Xc: uerror.c
  345. Xc: wmatch.c
  346. XCompressing Hash Table...
  347. XSorting Hash Table...
  348. XWriting `ID'...
  349. XNames: 593, Numbers: 64, Strings: 43, Solo: 119, Total: 697
  350. XOccurrances: 11.67, Load: 0.17, Probes: 1.07
  351. X
  352. XMkid(1) echoes the name of each file as it is scanned, prefixed by the
  353. Xname of the language it thinks the file is written in.  Mkid(1) reports
  354. Xhow many unique names and numbers were found, how many names occurred
  355. Xonly once, and the total for names and numbers.  It also reports the
  356. Xaverage number of occurrances for all names and numbers.  Next, there
  357. Xare some hash-table statistics on the load-factor and the average
  358. Xnumber of open-addressed probes.
  359. X
  360. XMkid(1) can take arguments from the command line, from stdin, or from
  361. Xa file.  A file full of filenames may also contain mkid options of the form
  362. X-<option>.  Filenames and options appear in the file one-per-line.  Typical
  363. Xusage for this feature is as follows:
  364. X
  365. X$ find . -name '*.[chys]' -print >IDFILES
  366. X$ mkid -aIDFILES
  367. X
  368. X-- or --
  369. X
  370. X$ find . -name '*.[chys]' -print |mkid -
  371. X
  372. XMkid(1) stashes the filenames and relevant arguments in the database
  373. Xitself.  It uses these to support the ``incremental-update' option.
  374. XIf invoked with `-u', mkid(1) checks the modification times of all
  375. Xconstituent files, and only re-scans those that are newer than the
  376. Xdatabase itself.  It is invoked like so:
  377. X
  378. X$ mkid -u
  379. X
  380. XIn summation, mkid(1) can get arguments from one of four places:
  381. X1) the command line, 2) a file, 3) stdin, 4) the database itself.
  382. X
  383. XMkid(1) accepts a number of scanner-specific arguments.  Generally,
  384. Xthese are introduced with `-S<lang>' where <lang> is the name of
  385. Xa language, such as `c' or `asm'.  You can get a scanner-specific
  386. Xusage-report with `-S<lang>?'  (Of course, the `?' must be escaped
  387. Xto get it past the shell)
  388. X
  389. XHere's scanner-usage for the assembly language scanner:
  390. X
  391. X$ mkid -Sasm\?
  392. XThe Assembler scanner arguments take the form -Sasm<arg>, where
  393. X<arg> is one of the following: (<cc> denotes one or more characters)
  394. X  -c<cc> . . . . <cc> introduce(s) a comment until end-of-line.
  395. X  (+|-)u . . . . (Do|Don't) strip a leading `_' from ids.
  396. X  (+|-)a<cc> . . Allow <cc> in ids, and (keep|ignore) those ids.
  397. X  (+|-)p . . . . (Do|Don't) handle C-preprocessor directives.
  398. X  (+|-)C . . . . (Do|Don't) handle C-style comments. (/* */)
  399. X
  400. X`-Sasm-c<cc>' tells the scanner what characters are used to introduce comments
  401. Xthat extend to end-of-line.
  402. X
  403. XUse `-Sasm+u' if your C compiler prepends leading underscores to external
  404. Xnames.  This way, mkid(1) will strip leading underscores, and the name
  405. X`foo' in a C source will be correctly associated with the name `_foo'
  406. Xin an assembler source.  If your compiler doesn't prepend leading
  407. Xunderscores, use `-Sasm-u'.
  408. X
  409. XMany assemblers allow special characters to be mixed with
  410. Xalpha-numerics in label, constant and register names.  Common choices
  411. Xare `.', `%', and `$'.  Thus, a label such as `L%123' should be scanned
  412. Xas one token, not broken up into the name `L' and the number 123.
  413. X`-Sasm-a%.' tells the scanner to allow `%' and `.' in tokens, but to throw
  414. Xaway tokens containing `%' or `.' `-Sasm+a%.' tells the scanner to keep such
  415. Xtokens and put them into the database.
  416. X
  417. X
  418. X`-Sasm+p' tells the scanner to handle `#include' and `#define' lines as
  419. Xin C source, and `-Sasm+C' tells it to ignore C-style comments.
  420. X
  421. XHere's the scanner-usage for C:
  422. X
  423. X$ mkid -Sc\?
  424. XThe C scanner arguments take the form -Sc<arg>, where <arg>
  425. Xis one of the following: (<cc> denotes one or more characters)
  426. X  (+|-)u . . . . (Do|Don't) strip a leading `_' from ids in strings.
  427. X  -s<cc> . . . . Allow <cc> in string ids.
  428. X
  429. XThe `+u' argument is akin to the argument for the assembly-language
  430. Xscanner.  Mkid(1) keeps the contents of quoted-strings if the string
  431. Xcontains a single valid C name and nothing else.  E.g.  mkid(1) would
  432. Xkeep the contents of "_proc".  Such strings are interesting because
  433. Xthey may contain symbol names that a program uses for nlist lookups.
  434. XSo, if your compiler prepends underscores to external symbols, use
  435. X`-Sc+u' so that mkid(1) will strip them back off.
  436. X
  437. XMkid(1) normally throws away the contents of quoted strings that have
  438. Xanything other than a single name in them.  You can tell mkid(1) to
  439. Xaccept additional characters in strings with `-Sc-s<cc>' where <cc> is
  440. Xone or more special characters.  E.g. `-Sc-s/.-:,' will include most of
  441. Xthe strings containing pathnames that you are likely to encounter.
  442. X
  443. XAnother class of scanner argument allows you to associate a suffix
  444. Xwith a language.  E.g. `-S.y=c' tells mkid(1) to use the C language
  445. Xscanner on all files ending with .y.  You can ask mkid(1) for the
  446. Xavailable scanners and associated suffixes like so:
  447. X
  448. X$ mkid -S\?=\?
  449. X.c=c, .h=c, .y=c, .s=asm, .p=pascal, .pas=pascal
  450. X
  451. XPlease note, mkid(1) is lying to you about its Pascal prowess!
  452. XAt the time of this posting, there are scanners for C and assembly
  453. Xlanguage sources.  There are also stubs for Pascal, Ada and LISP.  The
  454. Xscanners are very fast.  The assembly language scanner knows how
  455. Xto throw away C-style comments as well as the traditional `comment-
  456. Xcharacter-until-end-of-line' style.  In order to test new scanners,
  457. Xthere is a scanner driver called idx(1).  Idx(1) simply calls the
  458. Xscanner to get identifiers one-at-a-time prints them on stdout one-per-line.
  459. X
  460. XFor more information, read the manual pages!
  461. X
  462. XHappy Hacking,
  463. X--
  464. X-- Greg McGary
  465. X-- P.O. Box 286
  466. X-- Lincoln, MA  01773
  467. X--
  468. X-- 9/15/87
  469. X--
  470. X--    Until the end of 1987,
  471. X--    Consulting to Sun's East Coast Division:
  472. X--        gmcgary@ecd.sun.com
  473. X--        gmcgary@suneast.uu.net
  474. X--
  475. X--    After that, probably consulting in Europe...
  476. SHAR_EOF
  477. if test 16037 -ne "`wc -c < 'TUTORIAL'`"
  478. then
  479.     echo shar: error transmitting "'TUTORIAL'" '(should have been 16037 characters)'
  480. fi
  481. echo shar: extracting "'TODO'" '(546 characters)'
  482. sed 's/^X//' << \SHAR_EOF > 'TODO'
  483. XEnhancements:
  484. X~~~~~~~~~~~~~
  485. Xmkid:
  486. X    handle attributes: IDN_NOISE
  487. X    add makefile scanner
  488. X
  489. Xgetid-c:
  490. X    add stuff to recognize float & double constants properly.
  491. X
  492. X[lgea]id:
  493. X    recursively search sub-dirs for ID databases and optionally
  494. X        merge everything into one BIG list
  495. Xlid:
  496. X    print attribute flags, add cmd-line args to query by flags
  497. X    break out searching junk into lib-funcs that are useful to editors
  498. X
  499. XNew Applications:
  500. X~~~~~~~~~~~~~~~~~
  501. Xignid:
  502. X    frob the IDN_NOISE attribute of an id in an existing ID database.
  503. X        takes ids on command line or stdin.
  504. SHAR_EOF
  505. if test 546 -ne "`wc -c < 'TODO'`"
  506. then
  507.     echo shar: error transmitting "'TODO'" '(should have been 546 characters)'
  508. fi
  509. echo shar: extracting "'makefile'" '(3516 characters)'
  510. sed 's/^X//' << \SHAR_EOF > 'makefile'
  511. X#!/bin/make -f
  512. X
  513. X# Copyright (c) 1986, Greg McGary
  514. X# @(#)makefile    1.3 86/11/06
  515. X
  516. X# --------------------------------------------------------------------
  517. X# System Dependent Configuration:
  518. X#   Choose a pre-packaged set of options below, or roll your own.
  519. X#   The relevant options are as follows:
  520. X#
  521. X# * If you have the `PW' library which includes the regular-expression
  522. X#   funcions regcmp(3) and regex(3), then use `-DREGEX' in DEFS, and
  523. X#   `-lPW' in LIBS.  If you have the regular-expression functions
  524. X#   re_comp(3) and re_exec(3), use `-DRE_EXEC' in DEFS.  If you don't
  525. X#   have any regular-expression functions, don't add either to DEFS.
  526. X#
  527. X# * If you do not have the 4.2 directory access libraries, add `-lndir'
  528. X#   to LIBS, and define `-DNDIR' in DEFS. 
  529. X#
  530. X# * If your string libraries have index(3) and rindex(3) instead of
  531. X#   strchr(3) and strrchr(3), use `-DRINDEX' in DEFS.
  532. X#
  533. X# * If your compiler chokes on pointers to functions returning void,
  534. X#   use `-Dvoid=int' in DEFS.
  535. X#
  536. X# * If you have setlinebuf(3) in your stdio to set line-buffering on
  537. X#   a stream, use `-DERRLINEBUF' in DEFS.
  538. X#
  539. X# * If you have a System-III/V terminal driver, define `TERMIO' in DEFS.
  540. X#
  541. X# * If you have ranlib(1), define `RANLIB' as such.  If you don't have
  542. X#   it, set `RANLIB' to something harmless like `@:', or `echo'
  543. X# --------------------------------------------------------------------
  544. X
  545. X# DEFS    =    -DREGEX -DNDIR -DTERMIO    # typical System-V defs
  546. X# DEFS    =    -Dvoid=int -DRINDEX -DRE_EXEC -DNDIR    # typical V7 defs
  547. XDEFS    =    -Dvoid=int -DRINDEX -DRE_EXEC -DERRLINEBUF    # BSD defs
  548. X
  549. X# LIBS    =    -lndir -lPW    # typical System-V libs
  550. X# LIBS    =    -lndir    # typical V7 libs
  551. XLIBS    =    # typical BSD libs (none)
  552. X
  553. X#RANLIB    =    @:    # system doesn't have ranlib (Sys-V)
  554. XRANLIB    =    ranlib    # system has ranlib (typically V7 & BSD)
  555. X
  556. X# --------------------------------------------------------------------
  557. X# Compilation / Loading options:
  558. X#   Choose options to generate a system as an installed product,
  559. X#   for debugging, or for performance profiling.
  560. X# --------------------------------------------------------------------
  561. X
  562. X# CCFLG    =    -g -DDEBUG     # debugging
  563. X# CCFLG    =    -p    # profiling
  564. XCCFLG    =    -O    # production
  565. X
  566. X# LDFLG    =    -g    # debugging
  567. X# LDFLG    =    -p    # profiling
  568. XLDFLG    =    # production
  569. X
  570. X# --------------------------------------------------------------------
  571. X
  572. XSHELL =        /bin/sh
  573. XTARGETS =    libid.a $(PROGS)
  574. XPROGS =        mkid lid idx fid $(LIDLINKS)
  575. XDESTINATION_DIR = /usr/local
  576. X
  577. XLIDLINKS =     gid aid eid
  578. XCFLAGS =    $(CCFLG) -I. $(DEFS)
  579. XLDFLAGS =    $(LDFLG) libid.a $(LIBS)
  580. X
  581. XOFILES =    init.o getscan.o scan-c.o scan-asm.o bsearch.o hash.o \
  582. X        bitops.o basename.o gets0.o getsFF.o paths.o opensrc.o \
  583. X        stoi.o uerror.o document.o bitcount.o wmatch.o bitsvec.o \
  584. X        tty.o bzero.o
  585. X
  586. X# --------------------------------------------------------------------
  587. X
  588. Xall:        $(TARGETS)
  589. X
  590. Xlibid.a:    $(OFILES)
  591. X        ar rv $@ $?
  592. X        $(RANLIB) $@
  593. X
  594. Xmkid:        mkid.o libid.a
  595. X        $(CC) -o $@ $@.o $(LDFLAGS)
  596. X
  597. Xfid:        fid.o libid.a
  598. X        $(CC) -o $@ $@.o $(LDFLAGS)
  599. X
  600. Xlid:        lid.o libid.a
  601. X        $(CC) -o $@ $@.o $(LDFLAGS)
  602. X
  603. Xidx:        idx.o libid.a
  604. X        $(CC) -o $@ $@.o $(LDFLAGS)
  605. X
  606. X$(LIDLINKS): lid
  607. X        -/bin/rm -f $@
  608. X        ln lid $@
  609. X
  610. Xinstall:    $(PROGS)
  611. X        mv $(PROGS) $(DESTINATION_DIR)
  612. X
  613. Xclean:
  614. X        rm -f $(TARGETS) *.o
  615. X
  616. Xid.tar:
  617. X        cd ..; tar cvbf 20 id/id.tar id/*.[ch1-8] id/makefile id/TODO id/TUTORIAL
  618. X
  619. Xid.tar.Z:    id.tar
  620. X        compress -b 14 <id.tar >id.tar.Z
  621. X
  622. Xid.shar:    id.shar-1 id.shar-2 id.shar-3
  623. X
  624. Xid.shar-1:
  625. X        shar $(SHARFLAGS) TUTORIAL TODO makefile *.h *.[1-8] >$@
  626. X
  627. Xid.shar-2:
  628. X        shar $(SHARFLAGS) [a-l]*.c >$@
  629. X
  630. Xid.shar-3:
  631. X        shar $(SHARFLAGS) [m-z]*.c >$@
  632. SHAR_EOF
  633. if test 3516 -ne "`wc -c < 'makefile'`"
  634. then
  635.     echo shar: error transmitting "'makefile'" '(should have been 3516 characters)'
  636. fi
  637. echo shar: extracting "'bitops.h'" '(537 characters)'
  638. sed 's/^X//' << \SHAR_EOF > 'bitops.h'
  639. X/* Copyright (c) 1986, Greg McGary */
  640. X/* @(#)bitops.h    1.1 86/10/09 */
  641. X
  642. X#define    BITTST(ba, bn)    ((ba)[(bn) >> 3] &  (1 << ((bn) & 0x07)))
  643. X#define    BITSET(ba, bn)    ((ba)[(bn) >> 3] |= (1 << ((bn) & 0x07)))
  644. X#define    BITCLR(ba, bn)    ((ba)[(bn) >> 3] &=~(1 << ((bn) & 0x07)))
  645. X#define    BITAND(ba, bn)    ((ba)[(bn) >> 3] &= (1 << ((bn) & 0x07)))
  646. X#define    BITXOR(ba, bn)    ((ba)[(bn) >> 3] ^= (1 << ((bn) & 0x07)))
  647. X
  648. Xextern char *bitsand();
  649. Xextern char *bitsclr();
  650. Xextern char *bitsset();
  651. Xextern char *bitsxor();
  652. Xextern int bitsany();
  653. Xextern int bitstst();
  654. SHAR_EOF
  655. if test 537 -ne "`wc -c < 'bitops.h'`"
  656. then
  657.     echo shar: error transmitting "'bitops.h'" '(should have been 537 characters)'
  658. fi
  659. echo shar: extracting "'bool.h'" '(128 characters)'
  660. sed 's/^X//' << \SHAR_EOF > 'bool.h'
  661. X/* Copyright (c) 1986, Greg McGary */
  662. X/* @(#)bool.h    1.1 86/10/09 */
  663. X
  664. Xtypedef    int    bool;
  665. X#define    TRUE    (0==0)
  666. X#define    FALSE    (0!=0)
  667. SHAR_EOF
  668. if test 128 -ne "`wc -c < 'bool.h'`"
  669. then
  670.     echo shar: error transmitting "'bool.h'" '(should have been 128 characters)'
  671. fi
  672. echo shar: extracting "'extern.h'" '(1260 characters)'
  673. sed 's/^X//' << \SHAR_EOF > 'extern.h'
  674. X/* Copyright (c) 1986, Greg McGary */
  675. X/* @(#)extern.h    1.1 86/10/09 */
  676. X
  677. X/* miscellaneous external declarations */
  678. X
  679. Xextern FILE *initID();
  680. Xextern FILE *openSrcFILE();
  681. Xextern char *(*getScanner())();
  682. Xextern char *basename();
  683. Xextern char *bsearch();
  684. Xextern char *calloc();
  685. Xextern char *coRCS();
  686. Xextern char *dirname();
  687. Xextern char *getAsmId();
  688. Xextern char *getCId();
  689. Xextern char *getDirToName();
  690. Xextern char *getLanguage();
  691. Xextern char *getSCCS();
  692. Xextern char *getenv();
  693. Xextern char *hashSearch();
  694. Xextern char *intToStr();
  695. Xextern char *malloc();
  696. Xextern char *regcmp();
  697. Xextern char *regex();
  698. Xextern char *rootName();
  699. Xextern char *skipJunk();
  700. Xextern char *spanPath();
  701. Xextern char *suffName();
  702. Xextern char *uerror();
  703. Xextern int bitCount();
  704. Xextern int bitsCount();
  705. Xextern int bitsToVec();
  706. Xextern int canCrunch();
  707. Xextern int dtoi();
  708. Xextern int fgets0();
  709. Xextern int getsFF();
  710. Xextern int h1str();
  711. Xextern int h2str();
  712. Xextern int strToInt();
  713. Xextern int otoi();
  714. Xextern int radix();
  715. Xextern int stoi();
  716. Xextern int vecToBits();
  717. Xextern int wordMatch();
  718. Xextern int xtoi();
  719. Xextern void bzero();
  720. Xextern void document();
  721. Xextern void filerr();
  722. Xextern void setAsmArgs();
  723. Xextern void setCArgs();
  724. Xextern void setScanArgs();
  725. Xextern void skipFF();
  726. X
  727. Xextern char *MyName;
  728. Xextern int errno;
  729. SHAR_EOF
  730. if test 1260 -ne "`wc -c < 'extern.h'`"
  731. then
  732.     echo shar: error transmitting "'extern.h'" '(should have been 1260 characters)'
  733. fi
  734. echo shar: extracting "'id.h'" '(1716 characters)'
  735. sed 's/^X//' << \SHAR_EOF > 'id.h'
  736. X/* Copyright (c) 1986, Greg McGary */
  737. X/* @(#)id.h    1.1 86/10/09 */
  738. X
  739. X#define    IDFILE    "ID"
  740. X
  741. Xstruct idhead {
  742. X    char    idh_magic[2];    /* magic number */
  743. X#define    IDH_MAGIC "\311\304"    /* magic-number ("ID" with hi bits) */
  744. X    short    idh_vers;    /* id-file version number */
  745. X#define    IDH_VERS    2    /* current version */
  746. X    int    idh_argc;    /* # of args for mkid update */
  747. X    int    idh_pthc;    /* # of paths for mkid update */
  748. X    int    idh_namc;    /* # of identifiers */
  749. X    int    idh_vecc;    /* # of bytes in a path vector entry */
  750. X    int    idh_bsiz;    /* # of bytes in entry (bufsiz for lid) */
  751. X    long    idh_argo;    /* file offset of args for mkid update */
  752. X    long    idh_namo;    /* file offset of identifier names */
  753. X    long    idh_endo;    /* file offset of EOF */
  754. X};
  755. X
  756. Xstruct idarg {
  757. X    struct idarg    *ida_next;
  758. X    char    *ida_arg;
  759. X    int    ida_index;
  760. X    char    ida_flags;
  761. X#define    IDA_ADJUST    0x01
  762. X#define    IDA_SCAN    0x02
  763. X#define    IDA_PATH    0x04
  764. X#define    IDA_ARG        0x08
  765. X#define    IDA_BLANK    0x10
  766. X};
  767. X
  768. Xstruct idname {
  769. X    char    *idn_name;
  770. X    char    *idn_bitv;
  771. X    char    idn_flags;
  772. X#define    IDN_SOLO    0x01    /* occurs only once */
  773. X#define    IDN_NUMBER    0x02    /* is a number */
  774. X#define    IDN_NAME    0x04    /* is a name */
  775. X#define    IDN_STRING    0x08    /* is a string */
  776. X#define    IDN_LITERAL    0x10    /* occurs as a literal (not string) */
  777. X#define    IDN_NOISE    0x20    /* occurs very frequently */
  778. X};
  779. X
  780. X/*
  781. X    Extract the various logical fields of a name:
  782. X
  783. X    NAME: null-terminated ascii string
  784. X    TAG:  index of name within a sorted array of all names
  785. X    SOLO: boolean indicating that this name occurs exactly once
  786. X*/
  787. X#define    ID_PATHS(b) ((b)+strlen(b)+1)
  788. X#define    ID_FLAGS(b) (*(b))
  789. X#define    ID_STRING(b) ((b)+1)
  790. X
  791. X#define    NEW(type)    ((type *)calloc(1, sizeof(type)))
  792. X
  793. X#define    GETARG(argc, argv)    ((argc)--, *(argv)++)
  794. X#define    UNGETARG(argc, argv)    ((argc)++, *--(argv))
  795. SHAR_EOF
  796. if test 1716 -ne "`wc -c < 'id.h'`"
  797. then
  798.     echo shar: error transmitting "'id.h'" '(should have been 1716 characters)'
  799. fi
  800. echo shar: extracting "'patchlevel.h'" '(21 characters)'
  801. sed 's/^X//' << \SHAR_EOF > 'patchlevel.h'
  802. X#define PATCHLEVEL 0
  803. SHAR_EOF
  804. if test 21 -ne "`wc -c < 'patchlevel.h'`"
  805. then
  806.     echo shar: error transmitting "'patchlevel.h'" '(should have been 21 characters)'
  807. fi
  808. echo shar: extracting "'radix.h'" '(225 characters)'
  809. sed 's/^X//' << \SHAR_EOF > 'radix.h'
  810. X/* Copyright (c) 1986, Greg McGary */
  811. X/* @(#)radix.h    1.1 86/10/09 */
  812. X
  813. X#define    RADIX_DEC    (1 << (10 - 1))
  814. X#define    RADIX_OCT    (1 << (010 - 1))
  815. X#define    RADIX_HEX    (1 << (0x10 - 1))
  816. X#define    RADIX_ALL    (RADIX_DEC|RADIX_OCT|RADIX_HEX)
  817. SHAR_EOF
  818. if test 225 -ne "`wc -c < 'radix.h'`"
  819. then
  820.     echo shar: error transmitting "'radix.h'" '(should have been 225 characters)'
  821. fi
  822. echo shar: extracting "'string.h'" '(525 characters)'
  823. sed 's/^X//' << \SHAR_EOF > 'string.h'
  824. X/* Copyright (c) 1986, Greg McGary */
  825. X/* @(#)string.h    1.1 86/10/09 */
  826. X
  827. X#ifdef RINDEX
  828. X#define    strchr    index
  829. X#define    strrchr    rindex
  830. X#endif
  831. X
  832. Xextern char
  833. X    *strcpy(),
  834. X    *strncpy(),
  835. X    *strcat(),
  836. X    *strncat(),
  837. X    *strchr(),
  838. X    *strrchr(),
  839. X    *strpbrk(),
  840. X    *strtok();
  841. X
  842. Xextern long
  843. X    strtol();
  844. X
  845. Xextern char    *calloc();
  846. X
  847. X#define    strequ(s1, s2)        (strcmp((s1), (s2)) == 0)
  848. X#define    strnequ(s1, s2, n)    (strncmp((s1), (s2), (n)) == 0)
  849. X#define    strsav(s)        (strcpy(calloc(1, strlen(s)+1), (s)))
  850. X#define    strnsav(s, n)        (strncpy(calloc(1, (n)+1), (s), (n)))
  851. SHAR_EOF
  852. if test 525 -ne "`wc -c < 'string.h'`"
  853. then
  854.     echo shar: error transmitting "'string.h'" '(should have been 525 characters)'
  855. fi
  856. echo shar: extracting "'lid.1'" '(4020 characters)'
  857. sed 's/^X//' << \SHAR_EOF > 'lid.1'
  858. X.TH LID 1
  859. X.SH NAME
  860. Xlid, gid, eid \- query id database
  861. X.SH SYNOPSIS
  862. X.B lid
  863. X.RB [ \-f \^file]
  864. X.RB [ \-u \^n]
  865. X.RB [ \-edoxamse]
  866. Xpatterns...
  867. X.PP
  868. X.B gid
  869. X.RB [ \-f \^file]
  870. X.RB [ \-edoxamse]
  871. Xpatterns...
  872. X.PP
  873. X.B eid
  874. X.RB [ \-f \^file]
  875. X.RB [ \-doxamse]
  876. Xpatterns...
  877. X.PP
  878. X.B aid
  879. X.RB [ \-f \^file]
  880. X.RB [ \-doxams]
  881. Xpatterns...
  882. X.SH DESCRIPTION
  883. XThese commands provide a flexible query interface to the
  884. X.I id
  885. Xdatabase.
  886. X.I Lid\^
  887. Xdoes a lookup on
  888. X.IR patters
  889. Xand prints out lines in this way:
  890. X.PP
  891. X.nf
  892. Xidname        ../hdir/hfile.h ../cdir/{cfile1,cfile2}.c
  893. X.fi
  894. X.PP
  895. XNotice that multiple files with the same directory prefix
  896. Xand suffix are concatenated in the globbing-set-notation of
  897. X.IR csh (1).
  898. XAlso notice that all of the
  899. X.I id
  900. Xdatabase query commands adjust the list of pathnames to be relative
  901. Xto your current working directory, provided that
  902. X.IR mkid (1)
  903. Xwas used to build the database, and your working directory
  904. Xis located within the sub-tree covered by the
  905. X.I id
  906. Xdatabase.
  907. X.PP
  908. XIf multiple names match on pattern, then there will be one line
  909. Xof output per name.  The mnemonic significance of the name is
  910. X\fI\|l(ookup) id\fP.
  911. X.PP
  912. X.I Gid
  913. Xdoes a lookup and then searches for the names it matches in the
  914. Xfiles where they occur.  The mnemonic for this name is
  915. X\fI\|g(rep)id\fP. 
  916. X.PP
  917. X.I Eid
  918. Xdoes a lookup, and then invokes an editor on all files with
  919. Xthe matched name as an initial search string.  Of course, this
  920. Xname stands for
  921. X\fI\|e(dit) id\fP.
  922. X.PP
  923. X.I Eid
  924. Xuses four environment variables to control its invocation of the
  925. Xeditor.
  926. XNaturally,
  927. X.B EDITOR
  928. Xis used to locate the editing program.
  929. X.B EIDARG
  930. Xis a
  931. X.IR printf (3S)
  932. Xstring used to specify the form of the initial-search-string
  933. Xargument.  If the editor does not support such an argument,
  934. Xthis variable may be left unset.
  935. X.B EIDLDEL
  936. Xand
  937. X.B EIDRDEL
  938. Xspecify the form of the left and right word-delimiters respectively.
  939. XThe best way to explain the use of these last three variables is
  940. Xwith an example.  Here are the proper settings for vi(1):
  941. X.nf
  942. XEIDARG='+/%s/'    # initial search argument template
  943. XEIDLDEL='\\<'    # left word-delimiter
  944. XEIDRDEL='\\>'    # right word-delimiter
  945. X.fi
  946. X.PP
  947. X.I Patterns
  948. Xmay be simple alpha-numeric strings, or regular expressions in the
  949. Xstyle of
  950. X.IR regcmp (3).
  951. XIf the string contains no regular-expression meta-characters, it is
  952. Xsearched for as a
  953. X.IR word .
  954. XIf the string contains meta-characters, or if the \-e argument is
  955. Xsupplied, it is searched for as regular-expression.
  956. X.PP
  957. X.I Aid\^
  958. Xproduces output in the style of
  959. X.I lid\^
  960. Xbut its pattern arguments are searched for as substrings within
  961. Xthe identifiers in the database.  No regular-expression search
  962. Xis performed, even if the pattern contains meta-characters.
  963. XThe search is conducted in an alphabetic case insensitive manner.
  964. XThe mnemonic for this name is
  965. X\fI\|a(propos) id\fP. 
  966. X.PP
  967. XThe following options are recognized:
  968. X.TP 10
  969. X.BR \-f file\^
  970. XUse
  971. X.I file\^
  972. Xas the database instead of the default
  973. X.BR ID .
  974. X.TP 10
  975. X.BR \-u n
  976. XLists all identifiers in the database that are non-unique within the first
  977. X.I n
  978. Xcharacters.  This facility is particularly helpful when porting a program
  979. Xto a system whose compiler or linker has fewer significant characters
  980. Xfor identifiers.
  981. X.PP
  982. XThe remaining options are for use in conjunction with numeric patterns:
  983. X.TP 10
  984. X.B \-doxa
  985. XThese options may be specified in any combination.
  986. XThey limit numeric matches to specific radixes.
  987. XThe
  988. X.BR \-d ,
  989. X.BR \-o ,
  990. Xand
  991. X.B \-x
  992. Xoptions limit matches to decimal, octal, and hexadecimal respectively.
  993. XThe
  994. X.BR \-a
  995. Xoption is a shorthand for specifying all three radixes.
  996. X.PP
  997. XSearches for numbers 
  998. Xare conducted numerically rather than lexically, so that all
  999. Xrepresentations for a given number are potentially available
  1000. Xfrom a single search.
  1001. X.TP 10
  1002. X.B \-m
  1003. XMerge multiple lines of output into a single line.
  1004. X.TP 10
  1005. X.B \-s
  1006. XLimit the results of the search to identifiers that occur only
  1007. Xonce in the entire set of sources covered by the database.
  1008. XThis option is useful for finding identifiers that are defined
  1009. Xbut never used.
  1010. X.SH SEE ALSO
  1011. Xmkid(1),
  1012. Xfid(1).
  1013. SHAR_EOF
  1014. if test 4020 -ne "`wc -c < 'lid.1'`"
  1015. then
  1016.     echo shar: error transmitting "'lid.1'" '(should have been 4020 characters)'
  1017. fi
  1018. echo shar: extracting "'mkid.1'" '(4644 characters)'
  1019. sed 's/^X//' << \SHAR_EOF > 'mkid.1'
  1020. X.TH MKID 1
  1021. X.SH NAME
  1022. Xmkid \- make an id database
  1023. X.SH SYNOPSIS
  1024. X.B mkid
  1025. X.RB [ \-v ]
  1026. X.RB [ \-f \^out-file]
  1027. X.RB [ \-s \^directory]
  1028. X.RB [ \-r \^directory]
  1029. X.RB [ \-S \^scanarg]
  1030. X.RB [ \-a \^arg-file]
  1031. X.RB [ \- ]
  1032. X.RB [ \-u ]
  1033. X.RB [ files... ]
  1034. X.SH DESCRIPTION
  1035. X.I Mkid\^
  1036. Xbuilds a database that stores numbers and identifier names, as well
  1037. Xas the names of the files in which they occur.
  1038. X.I Mkid\^
  1039. Xis particularly useful with large programs spread out across multiple
  1040. Xsource files.  It serves as an aid for program maintenance and as a
  1041. X.I guide\^
  1042. Xfor perusing a program.
  1043. X.PP
  1044. XThe following options are recognized:
  1045. X.TP 10
  1046. X.B \-v
  1047. XVerbose.
  1048. XReport
  1049. X.IR mkid 's
  1050. Xprogress in building the database.  The output comes on standard error.
  1051. X.TP 10
  1052. X.BI \-f out-file\^
  1053. XWrite the finished database into
  1054. X.IR out-file .
  1055. X.B ID\^
  1056. Xis the default.
  1057. X.TP 10
  1058. X.BI \-s directory\^
  1059. X.TP 10
  1060. X.BI \-r directory\^
  1061. XIf
  1062. X.IR mkid 's
  1063. Xattempt to open a source-file fails, it will try to checkout the
  1064. Xcorresponding SCCS or RCS file if present.  The
  1065. X.B \-s
  1066. Xoption tells
  1067. X.I mkid\^
  1068. Xwhich directory holds the SCCS file.
  1069. XSimilarly, the
  1070. X.B \-r
  1071. Xoption tells
  1072. X.I mkid\^
  1073. Xwhich directory holds the RCS file.
  1074. XIf neither the RCS or SCCS directories are specified,
  1075. X.I mkid\^
  1076. Xwill first look for an SCCS file in the current directory, then in
  1077. X.BI sccs ,
  1078. Xand finally in
  1079. X.BI SCCS .
  1080. XIt will then look for an RCS file in the current directory, and finally in
  1081. X.BI RCS .
  1082. X.TP 10
  1083. X.BI \-a arg-file\^
  1084. XOpen and read
  1085. X.I arg-file\^
  1086. Xin order to obtain a list of source file arguments.  Source file names
  1087. Xmust appear one to a line.
  1088. X.BI \-S ,
  1089. X.BI \-r ,
  1090. Xand
  1091. X.BI \-s
  1092. Xarguments may also be placed one per line in
  1093. X.IR file .
  1094. XThey are distinguished from source file names by their leading `-'.  If a file name begins
  1095. Xwith `-', it can be distinguished from an argument by explicitly prepending the current
  1096. Xdirectory string: `./'.
  1097. X.TP 10
  1098. X.B \-
  1099. XThis operates in the same manner as the
  1100. X.B \-a
  1101. Xoption described above, but reads from the standard input instead of a file.
  1102. X.TP 10
  1103. X.B \-u
  1104. XUpdate an existing database.  Only those files that have been modified
  1105. Xsince the database was built will be rescanned.  This is a significant
  1106. Xtime-saver for updating large databases where few sources have changed.
  1107. X.TP 10
  1108. X.B files...
  1109. XIf neither the
  1110. X.BI \-a ,
  1111. X.BI \- ,
  1112. Xnor
  1113. X.BI \-u ,
  1114. Xarguments have been specified, take file names from the command line.
  1115. X.TP 10
  1116. X.BI \-S scanarg\^
  1117. X.I Mkid\^
  1118. Xscans source files in order to obtain numbers and identifier names.
  1119. XSince the lexical rules of languages differ,
  1120. X.I mkid\^
  1121. Xapplies a different scanning function to each language in order
  1122. Xto conform to that language's lexical rules.
  1123. X.I Mkid\^
  1124. Xdetermines the source file's language by examining its filename
  1125. Xsuffix which commonly occurs after a dot (`.').
  1126. XThe
  1127. X.B \-S
  1128. Xargument is a way of passing language specific arguments to the
  1129. Xscanner for that language.  This argument takes a number of forms:
  1130. X.br
  1131. X-S<suffix>=<language>
  1132. X.br
  1133. X-S<language>-<arg>
  1134. X.br
  1135. X+S-<arg>
  1136. X.br
  1137. XThe first form associates a suffix with a language.  You may find
  1138. Xout which suffixes are defined for which languages with the following
  1139. Xoptions: `-S<suffix>=?' tells which language is bound to
  1140. X.IR <suffix> ,
  1141. X`-S?=<language>' tells which suffixes are bound to 
  1142. X.IR <language> ,
  1143. Xand `-S?=?' reports all bindings between suffixes and languages.
  1144. X.PP
  1145. XThe second form passes an argument for processing by the scanner
  1146. Xfor a specific language.  The third form passes an argument to
  1147. Xall scanners.
  1148. X.PP
  1149. XYou may get a brief summary of the scanner-specific options for a
  1150. Xlanguage by supplying the following option: `-S<language>?'.
  1151. X.PP
  1152. XHere is a brief summary of the options for the
  1153. X.I `asm'\^
  1154. X(assembler) language.
  1155. X.PP
  1156. XThe
  1157. X.B \-u\^
  1158. Xoption controls whether or not the assembler scanner should strip
  1159. Xoff a leading
  1160. X.I underscore\^
  1161. X(`_') character.  If your assembler prepends an
  1162. X.I underscore\^
  1163. Xto external symbols, then you should tell the scanner to strip it
  1164. Xoff, so that references to the same symbol from assembly and from
  1165. Xa high-level language will look the same.
  1166. X.PP
  1167. XThe
  1168. X.B \-c<cc>\^
  1169. Xoption supplies the character(s) used to begin a comment that extends
  1170. Xto the end of the line.
  1171. X.PP
  1172. XThe
  1173. X.B \-a<cc>\^
  1174. Xoption indicates character(s) that are legal in names, in addition to
  1175. Xthe alpha-numeric characters.  If the option appears as `-a', names
  1176. Xthat contain these characters are ignored.  If it appears as `+a', these
  1177. Xnames are added to the database.
  1178. X.SH BUGS
  1179. XThis manual page needs to be more complete about the scanner-specific
  1180. Xarguments.
  1181. X.PP
  1182. XAt the moment, the only scanners implemented are for C and assembly
  1183. Xlanguage.  There ought to be scanners for Ada, Pascal, Fortran, Lisp,
  1184. Xnroff/troff, and TeX.
  1185. X.SH SEE ALSO
  1186. Xlid(1).
  1187. SHAR_EOF
  1188. if test 4644 -ne "`wc -c < 'mkid.1'`"
  1189. then
  1190.     echo shar: error transmitting "'mkid.1'" '(should have been 4644 characters)'
  1191. fi
  1192. #    End of shell archive
  1193. exit 0
  1194.